import { _ as __unplugin_components_4 } from "./SongList.js";
import { d as defineComponent, aO as useMusicStore, f as computed, cV as formatTimestamp, bI as renderIcon, d9 as updateDailySongsData, T as onActivated, o as onMounted, bM as resolveDirective, H as createElementBlock, j as openBlock, J as createBaseVNode, n as createVNode, m as withCtx, a7 as createTextVNode, ai as __unplugin_components_0, i as createBlock, k as unref, a8 as toDisplayString, ae as Transition, bN as withDirectives, a6 as Button, a5 as __unplugin_components_1, c5 as __unplugin_components_5, ar as __unplugin_components_3, K as _export_sfc } from "./stores.js";
import { d as openBatchList, p as player } from "./index.js";
const _hoisted_1 = { class: "daily-songs" };
const _hoisted_2 = { class: "title" };
const _hoisted_3 = { class: "tip" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "DailySongs",
  setup(__props) {
    const musicStore = useMusicStore();
    const updatedTime = computed(
      () => formatTimestamp(musicStore.dailySongsData.timestamp || 0, "MM-DD HH:mm")
    );
    const moreOptions = computed(() => [
      {
        label: "更新日推",
        key: "refresh",
        props: {
          onClick: async () => {
            await updateDailySongsData(true);
          }
        },
        icon: renderIcon("Refresh")
      },
      {
        label: "批量操作",
        key: "batch",
        props: {
          onClick: () => openBatchList(musicStore.dailySongsData.list, false)
        },
        icon: renderIcon("Batch")
      }
    ]);
    onActivated(updateDailySongsData);
    onMounted(updateDailySongsData);
    return (_ctx, _cache) => {
      const _component_n_text = __unplugin_components_0;
      const _component_SvgIcon = __unplugin_components_1;
      const _component_n_button = Button;
      const _component_n_dropdown = __unplugin_components_5;
      const _component_n_flex = __unplugin_components_3;
      const _component_SongList = __unplugin_components_4;
      const _directive_debounce = resolveDirective("debounce");
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createBaseVNode("div", _hoisted_2, [
          createVNode(_component_n_text, { class: "name" }, {
            default: withCtx(() => _cache[0] || (_cache[0] = [
              createTextVNode("每日推荐")
            ])),
            _: 1
          }),
          createBaseVNode("div", _hoisted_3, [
            createVNode(Transition, {
              name: "fade",
              mode: "out-in"
            }, {
              default: withCtx(() => [
                (openBlock(), createBlock(_component_n_text, {
                  key: unref(updatedTime),
                  depth: "3"
                }, {
                  default: withCtx(() => [
                    createTextVNode(" 根据你的音乐口味 · " + toDisplayString(unref(updatedTime) ? "更新于 " + unref(updatedTime) : "每日 6:00 更新"), 1)
                  ]),
                  _: 1
                }))
              ]),
              _: 1
            })
          ]),
          createVNode(_component_n_flex, { class: "menu" }, {
            default: withCtx(() => [
              withDirectives((openBlock(), createBlock(_component_n_button, {
                focusable: false,
                type: "primary",
                size: "large",
                strong: "",
                secondary: "",
                round: ""
              }, {
                icon: withCtx(() => [
                  createVNode(_component_SvgIcon, { name: "Play" })
                ]),
                default: withCtx(() => [
                  _cache[1] || (_cache[1] = createTextVNode(" 播放全部 "))
                ]),
                _: 1
              })), [
                [_directive_debounce, () => unref(player).updatePlayList(unref(musicStore).dailySongsData.list)]
              ]),
              createVNode(_component_n_dropdown, {
                options: unref(moreOptions),
                trigger: "click",
                placement: "bottom-start"
              }, {
                default: withCtx(() => [
                  createVNode(_component_n_button, {
                    focusable: false,
                    size: "large",
                    class: "more",
                    circle: "",
                    strong: "",
                    secondary: ""
                  }, {
                    icon: withCtx(() => [
                      createVNode(_component_SvgIcon, { name: "List" })
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              }, 8, ["options"])
            ]),
            _: 1
          })
        ]),
        createVNode(_component_SongList, {
          data: unref(musicStore).dailySongsData.list,
          loading: true,
          height: "auto"
        }, null, 8, ["data"])
      ]);
    };
  }
});
const DailySongs = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4c2f006d"]]);
export {
  DailySongs as default
};
